package com.party.core.model.gift;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @Author: Administrator.
 * @Description: 礼包目标类型
 * @Date:Created in 2017/11/14 0014 下午 13:54.
 */
public enum TargetCondition {
    ZC_SUPPORT("ZC_SUPPORT", "众筹支持者"), // 适用于支持了众筹的人员

    ZC_APPLY("ZC_APPLY", "众筹报名"), // 适用于报名产加了众筹的人员

    ZC_ING("ZC_ING", "众筹鼓励"), // 适用于众筹进行中的人员

    ZC_SUCCESS("ZC_SUCCESS", "众筹成功者"); // 适用于众筹成功的人员

    //状态码
    private String code;

    //状态值
    private String value;

    TargetCondition(String code, String value) {
        this.code = code;
        this.value = value;
    }

    /**
     * 根据状态码获取状态值
     *
     * @param code 状态码
     * @return 状态值
     */
    public static String getValue(String code) {
        for (TargetCondition TargetCondition : TargetCondition.values()) {
            if (TargetCondition.getCode().equals(code)) {
                return TargetCondition.getValue();
            }
        }
        return null;
    }


    /**
     * 枚举类型转换为map
     *
     * @return 转换后的map
     */
    public static Map<String, String> convertMap() {
        Map<String, String> map = Maps.newHashMap();
        for (TargetCondition TargetCondition : TargetCondition.values()) {
            map.put(TargetCondition.getCode(), TargetCondition.getValue());
        }
        return map;
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
